package com.hci.mercatinidinatale.db;

import java.io.Serializable;
import java.util.ArrayList;

import com.hci.mercatinidinatale.R;
import com.hci.mercatinidinatale.R.id;
import com.hci.mercatinidinatale.R.layout;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;

public class MyAdapter extends ArrayAdapter<Mercatino> implements Filterable
{
	private final Context context;
	private final ArrayList<Mercatino> mercatini;
	
	public MyAdapter(Context context, ArrayList<Mercatino> mercatini)
	{
		super(context, R.layout.list_items, mercatini);
		this.context = context;
		this.mercatini = mercatini;
	}
	
	public View getView(int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.list_items, parent, false);
		TextView labelView = (TextView) rowView.findViewById(R.id.txtRicercaMercatino);
		
        labelView.setText(mercatini.get(position).getNome());
        return rowView;
	}
}
